<include file="Public:header" />
<script type="text/javascript" src="__PUBLIC__/js/PCASClass.js" ></script>
<style>
    .a{
        display:block;
    }
    .form-p{line-height: 25px;height: 25px;}
    .product-a-line{border-left: 3px solid #19aa8d !important;}
    .product-list:hover{background-color: #f3f3f4;}
    .all_business{background-color: #fff;color: #00aaef;}
    .all_business_a{background-color: #00aaef;color: #fff !important;}
    .form-horizontal .control-label{color: #999;}
</style>
<div class="wrapper wrapper-content animated fadeIn" >
    <div class="ibox-content" style="padding-top:9px;padding-bottom:4px;">
        <include file="Public:alert" />
        <input type="hidden" id="oid" value="{$_GET['oid']}">
        <input type="hidden" id="member_id" value="{$member_info['member_id']}">
        <div class="row border-bottom">
            <div class="col-md-9">
                <div class="all-inline">
                    <span><img src="__PUBLIC__/img/customer_view_icon.png" style="margin-bottom:9px;" alt=""></span>
                    <h2 class="h2-customer-name" style="font-weight:400;color: #000;">{$member_info['name']}</h2>
                </div>
            </div>
            <div class="col-md-3">
                <a href="{:U('member/edit','id='.$member_info['member_id'])}" class="btn btn-outline btn-default pull-right" style="margin-right: 15px;"><i class="fa fa-pencil"></i>&nbsp;&nbsp;编辑</a>&nbsp;&nbsp;
            </div>
        </div>
        <div class="row" style="padding-top: 20px">
            <div class="col-md-9">
                <form role="form" class="form-horizontal view-group" method="post">
                    <div class="form-group">
                        <label class="col-lg-2 control-label">客户名称</label>
                        <div class="col-lg-4">
                            <p class="form-p ">
                                <span >{$member_info['name']}</span>
                            </p>
                        </div>
                        <label class="col-lg-2 control-label">尊称</label>
                        <div class="col-lg-4">
                            <p class="form-p">
                                <span >{$member_info['honorific']}</span>
                            </p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-2 control-label">联系电话</label>
                        <div class="col-lg-4">
                            <p class="form-p">
                                <span >{$member_info['telephone']}</span>
                            </p>
                        </div>
                        <label class="col-lg-2 control-label">出生年月</label>
                        <div class="col-lg-4">
                            <p class="form-p">
                                <span >{$member_info['birth']}</span>
                            </p>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-lg-2 control-label">注册时间</label>
                        <div class="col-lg-4">
                            <p class="form-p">
                                <span >{$member_info['create_time']|date = "Y-m-d H:i:s",###}</span>
                            </p>
                        </div>
                        <div class="col-lg-6"></div>
                    </div>
                </form>
            </div>
            <div class="col-md-3">
            </div>
        </div>
    </div>
</div>

<div class="wrapper wrapper-content animated fadeIn" style="padding-top:10px;">
    <div class="row" style="margin: 0">
        <div class="pull-left" style="width:26.222%;margin-bottom: 10px;">
            <div class="ibox-title clearfix">
                <div class="detail-title clearfix">
                    <div class="pull-left all-inline">
                        <img src="__PUBLIC__/img/chanpxx.png" alt="">&nbsp;
                        <div class="text-tag" style="top: 2px;color: #676A6C;">
                            <span>相关订单</span>
                        </div>
                    </div>
                    <div class="pull-left text-center" style="margin-left: 20px;">
                        <input type="hidden" id="maodian" />
                        <button class="btn btn-outline btn-success all_business_a" id="member-relation"  onclick="member_relation(this);" style="border-radius: 6px;width: 100%;line-height:30px;padding: 0px;width: 80px;" type="button">全部</button>
                    </div>
                </div>
            </div>
            <div class="ibox-content" style="padding: 0px 0px 20px;border-top:none;min-height:500px;">
                <volist name="member_info['order_list']" id="vo">
                    <div class="product-list" style="cursor:pointer;" rel="{$vo['order_id']}">
                        <!--竖线 -->
                        <div class="row ping-p">
                            <div class="col-md-1">
                                <div class="pull-left color-a">
                                    <a href="javascript:void(0);" rel="{$vo['order_id']}" style="font-size: 13px" class="product-a"><i class="fa fa-bookmark"></i></a>
                                </div>
                            </div>
                            <div class="col-md-10">
                                <p>{:date('Y-m-d H:i', $vo['create_time'])}</p>
                            </div>
                            <div class="col-md-1">
                                <div class="pull-right social-action dropdown">
                                    <span class="dropdown-toggle" data-toggle="dropdown">
                                        <i class="fa fa-angle-down" style="font-size:20px;cursor:pointer"></i>
                                    </span>
                                    <ul class="dropdown-menu m-t-xs">
                                        <li>
                                            <a href="javascript:void(0);" class="order_delete" rel="{$vo['order_id']}" >删除</a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        </div>
                        <div class="row ping-p">
                            <div class="col-md-3">
                                <p>订单编号</p>
                            </div>
                            <div class="col-md-7">
                                <p class="p-333">{$vo['code']}</p>
                            </div>
                            <div class="col-md-1"></div>
                        </div>
                        <div class="row ping-p edit-show"> 
                            <div class="col-md-3">
                                <p>相关产品</p>
                            </div>
                            <div class="col-md-7">
                                <p class="p-333" >{$vo['product_name']}（{$vo['product_count']}）</p>
                            </div>
    						<if condition="$content neq 'resource'">
                            <div class="col-md-1 color-a-edit"  style="font-size: 15px">
                                <a style="display:none;" rel="{$vo['order_id']}" class="editproduct" href="javascript:void(0);"><i class="fa fa-pencil"></i></a>
                            </div>
    						</if>
                        </div>
                        <div class="row ping-p">
                            <div class="col-md-3">
                                <p>订单状态</p>
                            </div>
                            <div class="col-md-4">
                                <p class="p-333">{$vo['status_name']}</p>
                            </div>
                            <div class="col-md-5"></div>
                        </div>
                    </div>
                </volist>
            </div>
        </div>
        <div class="pull-right" style="width:72.7%;margin-bottom: 10px;">
            <div class="tabs-container ibox-content product-content" style="min-height:608px;">
            </div>
        </div>
    </div>
</div>
<link href="__PUBLIC__/css/litebox.css" rel="stylesheet" type="text/css">
<script src="__PUBLIC__/js/litebox.min.js" type="text/javascript"></script>
<script src="__PUBLIC__/js/images-loaded.min.js" type="text/javascript"></script>
<div style="display:none" id="dialog-editproduct" title="编辑产品">
    <div class="spiner-example">
        <div class="sk-spinner sk-spinner-three-bounce">
            <div class="sk-bounce1"></div>
            <div class="sk-bounce2"></div>
            <div class="sk-bounce3"></div>
        </div>
    </div>
</div>
<div style="display:none" id="dialog-advance" title="状态变更">
    <div class="spiner-example">
        <div class="sk-spinner sk-spinner-three-bounce">
            <div class="sk-bounce1"></div>
            <div class="sk-bounce2"></div>
            <div class="sk-bounce3"></div>
        </div>
    </div>
</div>
<script type="text/javascript" language="javascript" >
    /**
     * 如果是图片时 双击可查看大图
     */
    $('.litebox_file').liteBox({
        revealSpeed: 400,
        background: 'rgba(0,0,0,.8)',
        overlayClose: true,
        escKey: true,
        navKey: true,
        errorMessage: '图片加载失败.'
    });

    $(document).ready(function(){
        /* 非ajax 提交后跳转 到指定的产品 */
        var oid = "<?php echo $_GET['oid']; ?>";
        order_id = Number(oid);
        if(order_id >= 1){
            // var rel = $('.product-list[rel='+order_id+']').find('.product-list');
            // product_detail(rel);
            $(".product-list[rel="+order_id+"]").trigger('click'); 
        }else{
            $('#member-relation').trigger('click');
        }
    });
    /*编辑商机*/
    $("#dialog-editproduct").dialog({
        autoOpen: false,
        modal: true,
        minWidth: 850,
        maxHeight: 400,
        position: ["center",100],
        buttons: {
            "确定": function () {
                var is_product = $('.cproduct_id').val();
                if(is_product == 'undefined' || is_product == '0'){
                    alert_crm('请至少选择一个产品！');
                }else{
                    $('#addbusiness_form').submit();
                    $(this).dialog("close");
                }
            },
            "取消": function () {
                $(this).html('');
                $(this).dialog("close");
            }
        },
        close: function() {
            /*关闭清空数据*/
        $(this).empty();
        }
    });
    $(".editproduct").click(function(){
        var order_id = $(this).attr('rel');
        $('#dialog-editproduct').dialog('open');
        $('#dialog-editproduct').load('{:U("product/mutildialog_product","order_id=")}'+order_id);
    });

    /*修改商机的 鼠标放上 效果*/
    $('.edit-show').mouseover(function(){
		$(this).find('a').show();
    });

    $('.edit-show').mouseout(function(){
        $(this).find('a').hide();
    });
    
    /*订单阶段*/
    $("#dialog-advance").dialog({
        autoOpen: false,
        modal: true,
        minWidth: 320,
        maxHeight: 800,
        position: ["center",100]
    });

    $(".advance").click(function(){
        var order_id = $(this).attr('rel');
        $('#dialog-advance').dialog('open');
        $('#dialog-advance').load('{:U("business/advance","id=")}'+order_id);
    });

/*product list 点击效果*/
$('.product-list').click(function(){
    // var rel = $(this).find('.product-a');
    var rel = $(this);
    var order_id = rel.attr('rel');
    var member_id = $('#member_id').val();
    var tab = window.location.hash;
    product_detail(rel);
    //url追加order_id
    var title = '';
    var url = './index.php?m=member&a=view&id='+member_id+'&oid='+order_id+tab;
    var state = {
        title: title,
        url: url
    };
    history.pushState(state, '', './index.php?m=member&a=view&id='+member_id+'&oid='+order_id+tab);
});

// 订单删除
$('.order_delete').click(function(){
    var order_id = $(this).attr('rel');
    swal({
        title: "您确定要删除这条订单吗？",
        text: "删除后将无法恢复，请谨慎操作！",
        type: "warning",   
        showCancelButton: true,   
        confirmButtonColor: "#DD6B55",   
        confirmButtonText: "是的，我要删除！",
        cancelButtonText:'让我再考虑一下…',
        closeOnConfirm:false,
        closeOnCancel:false
    },
    function(isConfirm){
        if (isConfirm) {
            $.ajax({
                type:'get',
                url: "{:U('order/delete','id=')}"+order_id,
                async: false,
                success: function (data) {
                    if (data.status == 1) {
                        swal("删除成功！", "您已经永久删除了信息！", "success");
                        location.reload();
                    }else{
                        swal({
                            title: "操作失败！",
                            text:data.info,
                            type: "error"
                        })
                        return false;
                    }
                },
                dataType: 'json'
            });
        } else {
            swal("已取消","您取消了删除操作！","error");
        }
    });
});

/*订单详情 加载的圈圈效果*/
var detail_html = '<div class="spiner-example">\
						<div class="sk-spinner sk-spinner-fading-circle">\
							<div class="sk-circle1 sk-circle"></div>\
							<div class="sk-circle2 sk-circle"></div>\
							<div class="sk-circle3 sk-circle"></div>\
							<div class="sk-circle4 sk-circle"></div>\
							<div class="sk-circle5 sk-circle"></div>\
							<div class="sk-circle6 sk-circle"></div>\
							<div class="sk-circle7 sk-circle"></div>\
							<div class="sk-circle8 sk-circle"></div>\
							<div class="sk-circle9 sk-circle"></div>\
							<div class="sk-circle10 sk-circle"></div>\
							<div class="sk-circle11 sk-circle"></div>\
							<div class="sk-circle12 sk-circle"></div>\
						</div>\
					</div>';
/*单个订单*///obj为要打开的标签页
function product_detail(e,obj){
    var order_id = $(e).attr('rel');
    $('#oid').val(order_id);
    $('.product-list').removeClass('product-a-line');
    $('#member-relation').removeClass('all_business_a');
    $('#member-relation').addClass('all_business');
    $(e).addClass('product-a-line');
    $('.product-list').css('background-color','#fff');
    $(e).css('background-color','#f3f3f4');
    $('.product-content').html(detail_html);
    $('.product-content').load("{:U('order/view_ajax')}", {id: order_id}, function(){
        $(obj).trigger('click');
    });
}
/*所有订单*///obj为要打开的标签页
function member_relation(e,obj){
    var maodian = $('#maodian').val();
    member_url_jump(maodian);
    $('.product-a').removeClass('product-a-color');
    $('.product-list').removeClass('product-a-line');
    $('.product-list').css('background-color','#fff');
    var member_id = "{$member_info['member_id']}";
    $('.product-content').html(detail_html);
    $('.product-content').load("{:U('order/view_ajax')}", {member_id: member_id}, function(){
        $(obj).trigger('click');
    });
}
function member_url_jump(maodian){
    var member_id = "{$member_info['member_id']}";
    $('#oid').val('');
    $('#member-relation').removeClass('all_business');
    $('#member-relation').addClass('all_business_a');
    var url = "{:U('member/view','id=')}"+member_id+maodian;
    window.history.replaceState({},0,window.location.protocol + "//"+window.location.host+url);
}
</script>
<include file="Public:footer" />